package com.example.springfeature.responsibilitychain.platform;

import com.example.springfeature.responsibilitychain.ProducerHandler;

/**
 * Created with IDEA
 * 模板类，用来规范处理器的执行逻辑，具体的处理方法交给子类去实现
 * @author: 董文辉
 * Date: 2019/2/22
 * Time: 10:21
 */
public abstract class CarProducerPlatForm implements ProducerHandler{
    private ProducerHandler nextProducer;
    @Override
    public void handleRequest(){
        //三个钩子方法
        doPrething();
        doHandler();
        doPostThing();
        if(nextProducer != null){
            nextProducer.handleRequest();
        }else{
            System.out.println("所有的生产者都已完成生产");
        }
    }
    @Override
    public void setNext(ProducerHandler next){
        this.nextProducer = next;
    }
    protected abstract  void doHandler();

    protected abstract void doPrething();

    protected abstract void doPostThing();
}
